package common

import (
	"context"
	"device-admin/internal/app/grpc/client"
	"device-admin/internal/app/grpc/protoc/system_admin"
)

// GetUserNameByID 获取用户名称
func GetUserNameByID(id string) (string, error) {
	cli, err := client.GetSystemAdminClient()
	if err != nil {
		return "", err
	}
	rsp, err := cli.UserName(context.Background(), &system_admin.UserNameReq{UserIds: []string{id}})
	if err != nil {
		return "", err
	}
	return rsp.UserNameMap[id], nil
}
